﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.ComponentModel
Public Class ExperienciaLaboral
    Inherits BDDatos
    Sub New()
        Me.Vista = "EXP_LABORAL"
    End Sub
    Public EMPRESA As String
    Public TELEFONO_EMP As String
    Public JEFE_INM As String
    Public FECHA_ING As String
    Public FECHA_RET As String
    Public CARGO As String
    Public SALARIO_INI As Decimal
    Public SALARIO_FIN As Decimal
    Public IDPK As String
    Public Function Insert() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Insert into Exp_Laboral(Cedula,Empresa,Telefono_Emp, Jefe_Inm, Fecha_Ing, Fecha_Ret, Cargo, Salario_Ini, Salario_Fin)" & _
            "Values(:Cedula, :Empresa,:Telefono_Emp, :Jefe_Inm, :Fecha_Ing, :Fecha_Ret, :Cargo, :Salario_Ini, :Salario_Fin)"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Empresa", UCase(Me.EMPRESA))
            Me.AsignarParametroCadena(":Telefono_Emp", Me.TELEFONO_EMP)
            Me.AsignarParametroCadena(":Jefe_Inm", UCase(Me.JEFE_INM))
            Me.AsignarParametroCadena(":Fecha_Ing", Me.FECHA_ING)
            Me.AsignarParametroCadena(":Fecha_Ret", Me.FECHA_RET)
            Me.AsignarParametroCadena(":Cargo", UCase(Me.CARGO))
            Me.AsignarParametroDecimal(":Salario_Ini", Me.SALARIO_INI)
            Me.AsignarParametroDecimal(":Salario_Fin", Me.SALARIO_FIN)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    Public Function Update() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Update Exp_Laboral set Empresa=:Empresa,Telefono_Emp=:Telefono_Emp, Jefe_Inm=:Jefe_Inm, Fecha_Ing=:Fecha_Ing, Fecha_Ret=:Fecha_Ret, Cargo=:Cargo, Salario_Ini=:Salario_Ini, Salario_Fin=:Salario_Fin Where Cedula=:Cedula And Id=:Id"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Empresa", UCase(Me.EMPRESA))
            Me.AsignarParametroCadena(":Telefono_Emp", Me.TELEFONO_EMP)
            Me.AsignarParametroCadena(":Jefe_Inm", UCase(Me.JEFE_INM))
            Me.AsignarParametroCadena(":Fecha_Ing", Me.FECHA_ING)
            Me.AsignarParametroCadena(":Fecha_Ret", Me.FECHA_RET)
            Me.AsignarParametroCadena(":Cargo", UCase(Me.CARGO))
            Me.AsignarParametroDecimal(":Salario_Ini", Me.SALARIO_INI)
            Me.AsignarParametroDecimal(":Salario_Fin", Me.SALARIO_FIN)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.AsignarParametroCadena(":Id", Me.IDPK)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado() As DataTable
        Me.Conectar()
        Me.querystring = "Select * from EXP_LABORAL where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado(ByVal Cedula As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from EXP_LABORAL where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Cedula)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetbyPK(ByVal Id As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from EXP_LABORAL where cedula=:cedula and Id=:Id"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Me.AsignarParametroCadena(":Id", Id)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    Public Function Delete(ByVal ID As String) As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Delete from EXP_LABORAL where Id=:Id and Cedula=:Cedula"
            Me.CrearComando(querystring)
            Me.AsignarParametroDecimal(":Id", ID)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
End Class
